public class ThreadDemo20 {
    private static Object locker = new Object();
    public static void main(String[] args) {
        Thread t= new Thread(() ->{
           synchronized (locker){
               System.out.println("t1 wait之前");
               try {
                   locker.wait();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               System.out.println("t1 wait之后");
           }
        });
        Thread t1 = new Thread(() ->{
           try {
               Thread.sleep(5000);
               synchronized (locker){
                   System.out.println("t2 notify之前");
                   locker.notify();
                   System.out.println("t2 notify之后");
               }
           }catch (InterruptedException e){
               e.printStackTrace();
           }
        });
        t.start();
        t1.start();
    }
}
